from typing import Union
from pydantic import BaseModel, Field
from tortoise.contrib.pydantic import PydanticModel, pydantic_queryset_creator, pydantic_model_creator

from models.order import ZhanGoods


class GoodsPydantic(BaseModel):
    name: str = Field(max_length=255)
    price: str = Field(min_length=1)
    status: float = Field(default=ZhanGoods.STATUS_OPEN)
    image: Union[str, None] = None
    description: str = Field(min_length=1)
    activity: Union[int, None] = None
    category: int = Field(default=ZhanGoods.CATEGORY_CHATGPT)
    stock: int = 9999


GoodsPydanticList = pydantic_queryset_creator(ZhanGoods)
GoodsPydanticModel = pydantic_model_creator(ZhanGoods)
